package com.gw.smscheck.service.sys.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gw.smscheck.dao.sys.LogMappingMapper;
import com.gw.smscheck.entity.sys.LogMapping;
import com.gw.smscheck.service.sys.LogMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogMappingServiceImpl implements LogMappingService {
	@Autowired
	private LogMappingMapper logMappingMapper;
	@Override
	public Integer add(LogMapping logMapping) {
		return logMappingMapper.add(logMapping);
	}
	@Override
	public List<LogMapping> findAll() {
		return logMappingMapper.findAll();
	}
	@Override
	public PageInfo<LogMapping> pageSelect(LogMapping dto) {
		PageHelper.startPage(dto.getPage(), dto.getRows(), "create_time desc");// 排序
		List<LogMapping> resultList = logMappingMapper.pageSelect(dto);
		PageInfo<LogMapping> pageInfo = new PageInfo<>(resultList);
		return pageInfo;
	}
	@Override
	public LogMapping findById(Integer dto) {
		return logMappingMapper.findById(dto);
	}
	@Override
	public Integer update(LogMapping logMapping) {
		return logMappingMapper.update(logMapping);
	}
	@Override
	public Integer delByIds(String[] ids) {
		return logMappingMapper.delByIds(ids);
	}

    /**
     * 根据url获取数据
	 * @param
     * @return
     */
	@Override
	public List<LogMapping> findByUrl(LogMapping logMapping) {
		if(logMapping.getUrl().trim() == null || "".equals(logMapping.getUrl().trim())){
			return null;
		}
		return logMappingMapper.findByUrl(logMapping);
	}

	/**
	 * 停用或删除
	 * @param logMapping
	 * @return
	 */
	@Override
	public Integer stopOrStartUse(LogMapping logMapping) {
		return logMappingMapper.stopOrStartUse(logMapping);
	}
}

